package tool

import (
	"crypto/md5"
	"fmt"
	"log"
)

func GenerateSignature(merchantno, params, signtype, key string, timestamp int64) (string, error) {
	times := fmt.Sprintf("%d", timestamp)

	// Append the secret and create the final string to be hashed
	finalStr := merchantno + params + signtype + times + key
	log.Println(finalStr)
	hash := md5.Sum([]byte(finalStr))
	signature := fmt.Sprintf("%x", hash)

	return signature, nil
}
